﻿package Util
{
	/**
	 * PHP远程调用工厂类
	 */
	public class RemotingFactory
	{
		public static const REMOTING_TYPE_BINARY:int = 1;
		public static const REMOTING_TYPE_SECURITY_BINARY:int = 2;
		
		/**
		 * 远程调用实例
		 */
		private static var _instance:IRemoting = null;
		
		/**
		 * 创建远程调用
		 * 
		 * @param String url
		 * @param String path
		 * @return IRemoting
		 */
		public static function create(url:String, path:String, type:int = REMOTING_TYPE_BINARY):IRemoting {
			if (null == _instance)
			{
				switch (type) 
				{
					case REMOTING_TYPE_BINARY:
					{
						_instance = new BinaryRemoting(url, path);
						break;
					}
					case REMOTING_TYPE_SECURITY_BINARY:
					{
						_instance = new SecurityBinaryRemoting(url, path);
						break;
					}
				}
			}
			
			return _instance;
		}
	}
}